$(function () {
    getDatas();

    var payment = $('#payment');
    $('#submitOrder').tap(function () {
        if ($('#numbs').text() > 0) {
            payment.css('display', 'block')
        }
    });
    $('#closeBtn').tap(function () {
        payment.css('display', 'none')
    });

    $('#speGoBack').tap(function () {
        var isLeave = confirm('确认要离开吗？');
        if (isLeave) {
            LsySession.removeItem('checkItems');
            window.history.back();
        }
    });

    function getDatas() {
        var ids = LsySession.getItem('checkItems');
        var option = {
            type: 'get',
            url: 'admin/confirm_order.php',
            data: {
                getType: 'getConfirm',
                ids: ids
            }
        };
        requestEvent(option, function (res) {
            createHtml(res);
        })
    }

    function createHtml(data) {
        var str = '';
        var total = 0;
        for (var i = 0, n = data.length; i < n; i++) {
            var price = Number(data[i].price).toFixed(2);
            total += data[i].price * data[i].num;
            str += ''
                + '<div class="proDetails">'
                + '<a class="clearFix" href="#">'
                + '<img src="' + data[i].imgSrc + '" alt="">'
                + '<div class="menuListRight">'
                + '<h5 class="listTitle">' + data[i].title + '</h5>'
                + '<p class="proColor">颜色:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<span>' + data[i].scolor + '</span>)</p>'
                + '<p class="price">￥<span>' + price + '</span></p>'
                + '<p class="number">X<span>' + data[i].num + '</span></p>'
                + '</div>'
                + '</a>'
                + '</div>'
        }
        $('#proBox').html(str);
        $('#total,#subtotal,#payments').text(total.toFixed(2));
        $('#numbs').text(n);
    }
});